//
//  YWVideoInternalBaseClass1.m
//
//  Created by Yeewii@hotmail com on 16/6/16
//  Copyright (c) 2016 __MyCompanyName__. All rights reserved.
//

#import "YWVideoInternalBaseClass1.h"
#import "YWVideoVideoTopic.h"


NSString *const kYWVideoInternalBaseClass1Ptime = @"ptime";
NSString *const kYWVideoInternalBaseClass1Videosource = @"videosource";
NSString *const kYWVideoInternalBaseClass1TopicImg = @"topicImg";
NSString *const kYWVideoInternalBaseClass1Title = @"title";
NSString *const kYWVideoInternalBaseClass1Sectiontitle = @"sectiontitle";
NSString *const kYWVideoInternalBaseClass1M3u8Url = @"m3u8_url";
NSString *const kYWVideoInternalBaseClass1Vid = @"vid";
NSString *const kYWVideoInternalBaseClass1TopicSid = @"topicSid";
NSString *const kYWVideoInternalBaseClass1Playersize = @"playersize";
NSString *const kYWVideoInternalBaseClass1TopicName = @"topicName";
NSString *const kYWVideoInternalBaseClass1ReplyCount = @"replyCount";
NSString *const kYWVideoInternalBaseClass1Prompt = @"prompt";
NSString *const kYWVideoInternalBaseClass1ReplyBoard = @"replyBoard";
NSString *const kYWVideoInternalBaseClass1Cover = @"cover";
NSString *const kYWVideoInternalBaseClass1PlayCount = @"playCount";
NSString *const kYWVideoInternalBaseClass1Length = @"length";
NSString *const kYWVideoInternalBaseClass1TopicDesc = @"topicDesc";
NSString *const kYWVideoInternalBaseClass1Replyid = @"replyid";
NSString *const kYWVideoInternalBaseClass1VideoTopic = @"videoTopic";
NSString *const kYWVideoInternalBaseClass1Mp4Url = @"mp4_url";
NSString *const kYWVideoInternalBaseClass1Description = @"description";


@interface YWVideoInternalBaseClass1 ()

- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;

@end

@implementation YWVideoInternalBaseClass1

@synthesize ptime = _ptime;
@synthesize videosource = _videosource;
@synthesize topicImg = _topicImg;
@synthesize title = _title;
@synthesize sectiontitle = _sectiontitle;
@synthesize m3u8Url = _m3u8Url;
@synthesize vid = _vid;
@synthesize topicSid = _topicSid;
@synthesize playersize = _playersize;
@synthesize topicName = _topicName;
@synthesize replyCount = _replyCount;
@synthesize prompt = _prompt;
@synthesize replyBoard = _replyBoard;
@synthesize cover = _cover;
@synthesize playCount = _playCount;
@synthesize length = _length;
@synthesize topicDesc = _topicDesc;
@synthesize replyid = _replyid;
@synthesize videoTopic = _videoTopic;
@synthesize mp4Url = _mp4Url;
@synthesize internalBaseClass1Description = _internalBaseClass1Description;


+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict
{
    return [[self alloc] initWithDictionary:dict];
}

- (instancetype)initWithDictionary:(NSDictionary *)dict
{
    self = [super init];
    
    // This check serves to make sure that a non-NSDictionary object
    // passed into the model class doesn't break the parsing.
    if(self && [dict isKindOfClass:[NSDictionary class]]) {
            self.ptime = [self objectOrNilForKey:kYWVideoInternalBaseClass1Ptime fromDictionary:dict];
            self.videosource = [self objectOrNilForKey:kYWVideoInternalBaseClass1Videosource fromDictionary:dict];
            self.topicImg = [self objectOrNilForKey:kYWVideoInternalBaseClass1TopicImg fromDictionary:dict];
            self.title = [self objectOrNilForKey:kYWVideoInternalBaseClass1Title fromDictionary:dict];
            self.sectiontitle = [self objectOrNilForKey:kYWVideoInternalBaseClass1Sectiontitle fromDictionary:dict];
            self.m3u8Url = [self objectOrNilForKey:kYWVideoInternalBaseClass1M3u8Url fromDictionary:dict];
            self.vid = [self objectOrNilForKey:kYWVideoInternalBaseClass1Vid fromDictionary:dict];
            self.topicSid = [self objectOrNilForKey:kYWVideoInternalBaseClass1TopicSid fromDictionary:dict];
            self.playersize = [[self objectOrNilForKey:kYWVideoInternalBaseClass1Playersize fromDictionary:dict] doubleValue];
            self.topicName = [self objectOrNilForKey:kYWVideoInternalBaseClass1TopicName fromDictionary:dict];
            self.replyCount = [[self objectOrNilForKey:kYWVideoInternalBaseClass1ReplyCount fromDictionary:dict] doubleValue];
            self.prompt = [self objectOrNilForKey:kYWVideoInternalBaseClass1Prompt fromDictionary:dict];
            self.replyBoard = [self objectOrNilForKey:kYWVideoInternalBaseClass1ReplyBoard fromDictionary:dict];
            self.cover = [self objectOrNilForKey:kYWVideoInternalBaseClass1Cover fromDictionary:dict];
            self.playCount = [[self objectOrNilForKey:kYWVideoInternalBaseClass1PlayCount fromDictionary:dict] doubleValue];
            self.length = [[self objectOrNilForKey:kYWVideoInternalBaseClass1Length fromDictionary:dict] doubleValue];
            self.topicDesc = [self objectOrNilForKey:kYWVideoInternalBaseClass1TopicDesc fromDictionary:dict];
            self.replyid = [self objectOrNilForKey:kYWVideoInternalBaseClass1Replyid fromDictionary:dict];
            self.videoTopic = [YWVideoVideoTopic modelObjectWithDictionary:[dict objectForKey:kYWVideoInternalBaseClass1VideoTopic]];
            self.mp4Url = [self objectOrNilForKey:kYWVideoInternalBaseClass1Mp4Url fromDictionary:dict];
            self.internalBaseClass1Description = [self objectOrNilForKey:kYWVideoInternalBaseClass1Description fromDictionary:dict];

    }
    
    return self;
    
}

- (NSDictionary *)dictionaryRepresentation
{
    NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
    [mutableDict setValue:self.ptime forKey:kYWVideoInternalBaseClass1Ptime];
    [mutableDict setValue:self.videosource forKey:kYWVideoInternalBaseClass1Videosource];
    [mutableDict setValue:self.topicImg forKey:kYWVideoInternalBaseClass1TopicImg];
    [mutableDict setValue:self.title forKey:kYWVideoInternalBaseClass1Title];
    [mutableDict setValue:self.sectiontitle forKey:kYWVideoInternalBaseClass1Sectiontitle];
    [mutableDict setValue:self.m3u8Url forKey:kYWVideoInternalBaseClass1M3u8Url];
    [mutableDict setValue:self.vid forKey:kYWVideoInternalBaseClass1Vid];
    [mutableDict setValue:self.topicSid forKey:kYWVideoInternalBaseClass1TopicSid];
    [mutableDict setValue:[NSNumber numberWithDouble:self.playersize] forKey:kYWVideoInternalBaseClass1Playersize];
    [mutableDict setValue:self.topicName forKey:kYWVideoInternalBaseClass1TopicName];
    [mutableDict setValue:[NSNumber numberWithDouble:self.replyCount] forKey:kYWVideoInternalBaseClass1ReplyCount];
    [mutableDict setValue:self.prompt forKey:kYWVideoInternalBaseClass1Prompt];
    [mutableDict setValue:self.replyBoard forKey:kYWVideoInternalBaseClass1ReplyBoard];
    [mutableDict setValue:self.cover forKey:kYWVideoInternalBaseClass1Cover];
    [mutableDict setValue:[NSNumber numberWithDouble:self.playCount] forKey:kYWVideoInternalBaseClass1PlayCount];
    [mutableDict setValue:[NSNumber numberWithDouble:self.length] forKey:kYWVideoInternalBaseClass1Length];
    [mutableDict setValue:self.topicDesc forKey:kYWVideoInternalBaseClass1TopicDesc];
    [mutableDict setValue:self.replyid forKey:kYWVideoInternalBaseClass1Replyid];
    [mutableDict setValue:[self.videoTopic dictionaryRepresentation] forKey:kYWVideoInternalBaseClass1VideoTopic];
    [mutableDict setValue:self.mp4Url forKey:kYWVideoInternalBaseClass1Mp4Url];
    [mutableDict setValue:self.internalBaseClass1Description forKey:kYWVideoInternalBaseClass1Description];

    return [NSDictionary dictionaryWithDictionary:mutableDict];
}

- (NSString *)description 
{
    return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
}

#pragma mark - Helper Method
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict
{
    id object = [dict objectForKey:aKey];
    return [object isEqual:[NSNull null]] ? nil : object;
}


#pragma mark - NSCoding Methods

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];

    self.ptime = [aDecoder decodeObjectForKey:kYWVideoInternalBaseClass1Ptime];
    self.videosource = [aDecoder decodeObjectForKey:kYWVideoInternalBaseClass1Videosource];
    self.topicImg = [aDecoder decodeObjectForKey:kYWVideoInternalBaseClass1TopicImg];
    self.title = [aDecoder decodeObjectForKey:kYWVideoInternalBaseClass1Title];
    self.sectiontitle = [aDecoder decodeObjectForKey:kYWVideoInternalBaseClass1Sectiontitle];
    self.m3u8Url = [aDecoder decodeObjectForKey:kYWVideoInternalBaseClass1M3u8Url];
    self.vid = [aDecoder decodeObjectForKey:kYWVideoInternalBaseClass1Vid];
    self.topicSid = [aDecoder decodeObjectForKey:kYWVideoInternalBaseClass1TopicSid];
    self.playersize = [aDecoder decodeDoubleForKey:kYWVideoInternalBaseClass1Playersize];
    self.topicName = [aDecoder decodeObjectForKey:kYWVideoInternalBaseClass1TopicName];
    self.replyCount = [aDecoder decodeDoubleForKey:kYWVideoInternalBaseClass1ReplyCount];
    self.prompt = [aDecoder decodeObjectForKey:kYWVideoInternalBaseClass1Prompt];
    self.replyBoard = [aDecoder decodeObjectForKey:kYWVideoInternalBaseClass1ReplyBoard];
    self.cover = [aDecoder decodeObjectForKey:kYWVideoInternalBaseClass1Cover];
    self.playCount = [aDecoder decodeDoubleForKey:kYWVideoInternalBaseClass1PlayCount];
    self.length = [aDecoder decodeDoubleForKey:kYWVideoInternalBaseClass1Length];
    self.topicDesc = [aDecoder decodeObjectForKey:kYWVideoInternalBaseClass1TopicDesc];
    self.replyid = [aDecoder decodeObjectForKey:kYWVideoInternalBaseClass1Replyid];
    self.videoTopic = [aDecoder decodeObjectForKey:kYWVideoInternalBaseClass1VideoTopic];
    self.mp4Url = [aDecoder decodeObjectForKey:kYWVideoInternalBaseClass1Mp4Url];
    self.internalBaseClass1Description = [aDecoder decodeObjectForKey:kYWVideoInternalBaseClass1Description];
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{

    [aCoder encodeObject:_ptime forKey:kYWVideoInternalBaseClass1Ptime];
    [aCoder encodeObject:_videosource forKey:kYWVideoInternalBaseClass1Videosource];
    [aCoder encodeObject:_topicImg forKey:kYWVideoInternalBaseClass1TopicImg];
    [aCoder encodeObject:_title forKey:kYWVideoInternalBaseClass1Title];
    [aCoder encodeObject:_sectiontitle forKey:kYWVideoInternalBaseClass1Sectiontitle];
    [aCoder encodeObject:_m3u8Url forKey:kYWVideoInternalBaseClass1M3u8Url];
    [aCoder encodeObject:_vid forKey:kYWVideoInternalBaseClass1Vid];
    [aCoder encodeObject:_topicSid forKey:kYWVideoInternalBaseClass1TopicSid];
    [aCoder encodeDouble:_playersize forKey:kYWVideoInternalBaseClass1Playersize];
    [aCoder encodeObject:_topicName forKey:kYWVideoInternalBaseClass1TopicName];
    [aCoder encodeDouble:_replyCount forKey:kYWVideoInternalBaseClass1ReplyCount];
    [aCoder encodeObject:_prompt forKey:kYWVideoInternalBaseClass1Prompt];
    [aCoder encodeObject:_replyBoard forKey:kYWVideoInternalBaseClass1ReplyBoard];
    [aCoder encodeObject:_cover forKey:kYWVideoInternalBaseClass1Cover];
    [aCoder encodeDouble:_playCount forKey:kYWVideoInternalBaseClass1PlayCount];
    [aCoder encodeDouble:_length forKey:kYWVideoInternalBaseClass1Length];
    [aCoder encodeObject:_topicDesc forKey:kYWVideoInternalBaseClass1TopicDesc];
    [aCoder encodeObject:_replyid forKey:kYWVideoInternalBaseClass1Replyid];
    [aCoder encodeObject:_videoTopic forKey:kYWVideoInternalBaseClass1VideoTopic];
    [aCoder encodeObject:_mp4Url forKey:kYWVideoInternalBaseClass1Mp4Url];
    [aCoder encodeObject:_internalBaseClass1Description forKey:kYWVideoInternalBaseClass1Description];
}

- (id)copyWithZone:(NSZone *)zone
{
    YWVideoInternalBaseClass1 *copy = [[YWVideoInternalBaseClass1 alloc] init];
    
    if (copy) {

        copy.ptime = [self.ptime copyWithZone:zone];
        copy.videosource = [self.videosource copyWithZone:zone];
        copy.topicImg = [self.topicImg copyWithZone:zone];
        copy.title = [self.title copyWithZone:zone];
        copy.sectiontitle = [self.sectiontitle copyWithZone:zone];
        copy.m3u8Url = [self.m3u8Url copyWithZone:zone];
        copy.vid = [self.vid copyWithZone:zone];
        copy.topicSid = [self.topicSid copyWithZone:zone];
        copy.playersize = self.playersize;
        copy.topicName = [self.topicName copyWithZone:zone];
        copy.replyCount = self.replyCount;
        copy.prompt = [self.prompt copyWithZone:zone];
        copy.replyBoard = [self.replyBoard copyWithZone:zone];
        copy.cover = [self.cover copyWithZone:zone];
        copy.playCount = self.playCount;
        copy.length = self.length;
        copy.topicDesc = [self.topicDesc copyWithZone:zone];
        copy.replyid = [self.replyid copyWithZone:zone];
        copy.videoTopic = [self.videoTopic copyWithZone:zone];
        copy.mp4Url = [self.mp4Url copyWithZone:zone];
        copy.internalBaseClass1Description = [self.internalBaseClass1Description copyWithZone:zone];
    }
    
    return copy;
}


@end
